$(function(){
	/*点击评论按钮，提交数据到comment_info.php进行后台处理*/
	$("#comment_submit").live('click',function(){
		var commentClick = $(this);
		
		/*取得该微博的id号*/
		var weibo_id = $(this).prevAll("#weibo_id").text();
		
		/*取得评论框里面的内容*/
		var comment_info = $(this).prevAll(".comment_info").text();
		
		/*如果评论框为空，则返回；后则提交*/
		if (!comment_info) {
			return false;
		}
		else {
			$.ajax({
				type: "POST",
				url: "php_ajax/comment_info.php",
				dataType: "html",
				cache: "false",
				data: {comment_content: comment_info, w_id: weibo_id},
				success: function(){
					commentClick.prevAll(".comment_info").text("");
					refresh(weibo_id,commentClick);
				}
			});
		}	
	});
	
	function refresh(weibo_id,commentClick){
		/*刷新评论内容*/
		$.ajax({
			type: "POST",
			url: "php_ajax/load_comment.php",
			dataTpe: "html",
			cache: false,
			data: {w_id: weibo_id},
			success: function(data){
				commentClick.next("#comment_wrap").empty().html(data);
			}
		});
		
		/*刷新评论数*/
		$.ajax({
			type: "POST",
			url: "php_ajax/load_comment_num.php",
			dataType: "html",
			cache: false,
			data: {w_id: weibo_id},
			success: function(data){
				commentClick.parent().parent().prevAll(".weibo_button").find("a:contains('评论')").empty().html("评论("+data+")");
			}
		});
	}
	return;
});